Libraries

Stocks gathering

Funções - retornos e acf

Séries de fechamento, retornos e retornos quadrados

Os retornos aparentemente são estacionários. Iremos fazer o teste de ljung-box para confirmar o ruído branco nos resíduos e também realizar o teste de raíz unitária.

ACF

## 
##  Box-Ljung test
## 
## data:  df
## X-squared = 26.875, df = 1, p-value = 2.171e-07
## 
## 
##  Augmented Dickey-Fuller Test
## 
## data:  df_box$ret.closing.prices
## Dickey-Fuller = -13.704, Lag order = 14, p-value = 0.01
## alternative hypothesis: stationary
## 
## 
##  ARCH LM-test; Null hypothesis: no ARCH effects
## 
## data:  df_box$ret.closing.prices
## Chi-squared = 101.06, df = 12, p-value = 3.454e-16

## 
##  Box-Ljung test
## 
## data:  df
## X-squared = 68.531, df = 1, p-value < 2.2e-16
## 
## 
##  Augmented Dickey-Fuller Test
## 
## data:  df_box$ret.closing.prices
## Dickey-Fuller = -15, Lag order = 14, p-value = 0.01
## alternative hypothesis: stationary
## 
## 
##  ARCH LM-test; Null hypothesis: no ARCH effects
## 
## data:  df_box$ret.closing.prices
## Chi-squared = 462.56, df = 12, p-value < 2.2e-16

## 
##  Box-Ljung test
## 
## data:  df
## X-squared = 0.17805, df = 1, p-value = 0.6731
## 
## 
##  Augmented Dickey-Fuller Test
## 
## data:  df_box$ret.closing.prices
## Dickey-Fuller = -13.735, Lag order = 14, p-value = 0.01
## alternative hypothesis: stationary
## 
## 
##  ARCH LM-test; Null hypothesis: no ARCH effects
## 
## data:  df_box$ret.closing.prices
## Chi-squared = 101.18, df = 12, p-value = 3.263e-16

## 
##  Box-Ljung test
## 
## data:  df
## X-squared = 0.020172, df = 1, p-value = 0.8871
## 
## 
##  Augmented Dickey-Fuller Test
## 
## data:  df_box$ret.closing.prices
## Dickey-Fuller = -13.687, Lag order = 14, p-value = 0.01
## alternative hypothesis: stationary
## 
## 
##  ARCH LM-test; Null hypothesis: no ARCH effects
## 
## data:  df_box$ret.closing.prices
## Chi-squared = 449.86, df = 12, p-value < 2.2e-16

## 
##  Box-Ljung test
## 
## data:  df
## X-squared = 9.0881, df = 1, p-value = 0.002573
## 
## 
##  Augmented Dickey-Fuller Test
## 
## data:  df_box$ret.closing.prices
## Dickey-Fuller = -13.57, Lag order = 14, p-value = 0.01
## alternative hypothesis: stationary
## 
## 
##  ARCH LM-test; Null hypothesis: no ARCH effects
## 
## data:  df_box$ret.closing.prices
## Chi-squared = 620.61, df = 12, p-value < 2.2e-16

## 
##  Box-Ljung test
## 
## data:  df
## X-squared = 46.137, df = 1, p-value = 1.103e-11
## 
## 
##  Augmented Dickey-Fuller Test
## 
## data:  df_box$ret.closing.prices
## Dickey-Fuller = -15.484, Lag order = 14, p-value = 0.01
## alternative hypothesis: stationary
## 
## 
##  ARCH LM-test; Null hypothesis: no ARCH effects
## 
## data:  df_box$ret.closing.prices
## Chi-squared = 463.78, df = 12, p-value < 2.2e-16

Residual distribution

Procurando o melhor modelo usando garchmodels

Obtendo melhores modelos

Ajustando garch para os modelos após encontrar os melhores resultados

Obtendo as previsões futuras

Analisando CAPM

Qual o risco de cada ação em relação ao mercado?

Calculando beta do portfolio

Retornos do portfolio e modelo de volatilidade

Dynamic model - CAPM